#include<stdio.h>
static int Area(int _width, int _height);//面积
static int AroundLength(int _width, int _height);//周长
/*定义长方形结构体类型*/
typedef struct 
{
    int width;//宽度
    int height;//高度
    int (*SelFunctionPt)(int, int);
} Rect_t;

int main(void)
{
    Rect_t MyRect;
    int opt;
    int result;
    printf("Please input the width\n");
    scanf("%d", &MyRect.width);
    printf("Please input the height\n");
    scanf("%d", &MyRect.height);
    printf("Please select the function: 0-area, 1-around legnth");
    scanf("%d", &opt);
    switch (opt)
    {
    case 0:MyRect.SelFunctionPt = Area;
        break;
    case 1:MyRect.SelFunctionPt = AroundLength;
        break;    
    default:MyRect.SelFunctionPt = NULL;
        break;
    }
    if(MyRect.SelFunctionPt != NULL)
    {
        result = MyRect.SelFunctionPt(MyRect.width, MyRect.height);
        printf("The result is %d", result);
    }
    else
    {
        printf("error input");
    }
    
    return 0;
}

static int Area(int _width, int _height)
{
    return _width * _height;
}
static int AroundLength(int _width, int _height)
{
    return (_width + _height) * 2;
}
